---
layout: "default"
title: "print"
description: "Swift documentation for 'print': Writes the textual representations of the given items into the standard."
keywords: "print,func,swift,documentation"
root: "/v4.2"
---

<div class="declaration" id="func-print_-any-separator_-string-terminator_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-print_-any-separator_-string-terminator_-string">func print(<wbr>_:<wbr> Any..., separator:<wbr> String, terminator: String)</a>
        
<div class="comment collapse" id="comment-func-print_-any-separator_-string-terminator_-string"><div class="p">
    <p>Writes the textual representations of the given items into the standard
output.</p>

<p>You can pass zero or more items to the <code>print(_:separator:terminator:)</code>
function. The textual representation for each item is the same as that
obtained by calling <code>String(item)</code>. The following example prints a string,
a closed range of integers, and a group of floating-point values to
standard output:</p>

<pre><code class="language-swift">print(&quot;One two three four five&quot;)
// Prints &quot;One two three four five&quot;

print(1...5)
// Prints &quot;1...5&quot;

print(1.0, 2.0, 3.0, 4.0, 5.0)
// Prints &quot;1.0 2.0 3.0 4.0 5.0&quot;</code></pre>

<p>To print the items separated by something other than a space, pass a string
as <code>separator</code>.</p>

<pre><code class="language-swift">print(1.0, 2.0, 3.0, 4.0, 5.0, separator: &quot; ... &quot;)
// Prints &quot;1.0 ... 2.0 ... 3.0 ... 4.0 ... 5.0&quot;</code></pre>

<p>The output from each call to <code>print(_:separator:terminator:)</code> includes a
newline by default. To print the items without a trailing newline, pass an
empty string as <code>terminator</code>.</p>

<pre><code class="language-swift">for n in 1...5 {
    print(n, terminator: &quot;&quot;)
}
// Prints &quot;12345&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>items:</strong> Zero or more items to print.
  <strong>separator:</strong> A string to print between each item. The default is a single
    space (<code>&quot; &quot;</code>).
  <strong>terminator:</strong> The string to print after all items have been printed. The
    default is a newline (<code>&quot;\n&quot;</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func print(_ items: Any..., separator: String = default, terminator: String = default)</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-print-target_-any-separator_-string-terminator_-string-to_-inout-target">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-print-target_-any-separator_-string-terminator_-string-to_-inout-target">func print&lt;Target&gt;(<wbr>_:<wbr> Any..., separator:<wbr> String, terminator:<wbr> String, to: inout Target)</a>
        
<div class="comment collapse" id="comment-func-print-target_-any-separator_-string-terminator_-string-to_-inout-target"><div class="p">
    <p>Writes the textual representations of the given items into the given output
stream.</p>

<p>You can pass zero or more items to the <code>print(_:separator:terminator:to:)</code>
function. The textual representation for each item is the same as that
obtained by calling <code>String(item)</code>. The following example prints a closed
range of integers to a string:</p>

<pre><code class="language-swift">var range = &quot;My range: &quot;
print(1...5, to: &amp;range)
// range == &quot;My range: 1...5\n&quot;</code></pre>

<p>To print the items separated by something other than a space, pass a string
as <code>separator</code>.</p>

<pre><code class="language-swift">var separated = &quot;&quot;
print(1.0, 2.0, 3.0, 4.0, 5.0, separator: &quot; ... &quot;, to: &amp;separated)
// separated == &quot;1.0 ... 2.0 ... 3.0 ... 4.0 ... 5.0\n&quot;</code></pre>

<p>The output from each call to <code>print(_:separator:terminator:to:)</code> includes a
newline by default. To print the items without a trailing newline, pass an
empty string as <code>terminator</code>.</p>

<pre><code class="language-swift">var numbers = &quot;&quot;
for n in 1...5 {
    print(n, terminator: &quot;&quot;, to: &amp;numbers)
}
// numbers == &quot;12345&quot;</code></pre>

<p><strong>Parameters:</strong>
  <strong>items:</strong> Zero or more items to print.
  <strong>separator:</strong> A string to print between each item. The default is a single
    space (<code>&quot; &quot;</code>).
  <strong>terminator:</strong> The string to print after all items have been printed. The
    default is a newline (<code>&quot;\n&quot;</code>).
  <strong>output:</strong> An output stream to receive the text representation of each
    item.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func print&lt;Target&gt;(_ items: Any..., separator: String = default, terminator: String = default, to output: inout Target)</code>
    
    
</div></div>
</div>
